<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>Named Method Injection</title></head>
<body>
<h3>Overview</h3>

<p>This is where a component has an empty constructor with
    dependencies passed in via setters and matching done via the method name (after 'set').  Matches are against named components.</p>

<div class="source">
	<pre>public class FruitBasket {
    public void setOrange(String orange) { ... }
    public void setPear(String pear) { ... }
    public void setBanana(String banana) { ... }
    // other methods
}</pre>
</div>
<h3>Usage</h3>

<div class="source"><pre>
pico = new DefaultPicoContainer(new NamedMethodInjection();
pico.addConfig("orange" , new Seville());
pico.addConfig("pear" , new Bartlett());
pico.addConfig("Banana" , new Cavendish());
pico.addComponent(FruitBasket.class);
// etc
FruitBasket basket = pico.getComponent(FruitBasket.class);</pre>
</div>
<p>
    Yes that's right, there's no constructor needed. It means that for a
    Unit Test, you cannot simply 'new' the class without some lines of code to
    populate the dependency fields via setters.</p>

<p>The component factory for this is a class<strong>
    NamedMethodInjection</strong>. It only handles named-method
    injection for components.</p>
</body>
</html>
